package org.jeecg.common.exception;


import org.jeecg.common.response.CommonCode;
import org.jeecg.common.response.ResultCode;

/**
 * 业务相关所有异常处理类
 *
 * @Author: Guoji Shen
 * @Date: 2021/11/8 10:36
 */
public class BizException extends RuntimeException {

    private int code;
    private String message;

    public BizException(ResultCode statusCode) {
        super();
        this.code = statusCode.code();
        this.message = statusCode.msg();
    }


    public BizException(ResultCode statusCode, String message) {
        super();
        this.code = statusCode.code();
        this.message = statusCode.msg() + ":" + message;
    }
    public BizException(int code, String message) {
        super();
        this.message = message;
        this.code = code;
    }

    public BizException(String message) {
        super();
        this.code = CommonCode.BIZ_FAILURE.getCode();
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}